package cn.nosql.tools;

import org.junit.Test;

import java.nio.ByteBuffer;
import java.util.List;

public class MyClientCase {
    /**
     * 定义 nosql
     * */
    @Test
    public void test_1()
    {
        MyClient myClient = new MyClient();
        System.out.println(myClient.executeSqlQuery("{'name': 'nosql_cache', fileName: '/Users/chenfei/temp/my_tmp.db'}"));
        //myClient.executeNoSql("nosql_cache", "set", MyConvertUtil.toByteBuffer(new Object[] {1, "吴大富"}));
        //System.out.println(myClient.executeNoSql("nosql_cache", "set", MyConvertUtil.toByteBuffer(new Object[] {1, "吴大富"})));
        //System.out.println(myClient.executeNoSql("nosql_cache", "get", MyConvertUtil.toByteBuffer(1)));
        System.out.println("OK");
    }

    /**
     * 添加数据
     * */
    @Test
    public void set_case()
    {
        MyClient myClient = new MyClient();
        //ByteBuffer buffer = MyConvertUtil.toByteBuffer(new Object[] {8, "美羊羊是大美女！"});
        List<Byte> buffer = MyConvertUtil.objToListBytes(new Object[] {8, "美羊羊是大美女！"});
        String rs = (String) MyConvertUtil.restoreToObject(myClient.executeNoSql("nosql_cache", "set", buffer));
        System.out.println(rs);
        //System.out.println(MyConvertUtil.toObj(myClient.executeNoSql("nosql_cache", "set", MyConvertUtil.toByteBuffer(new Object[] {8, "美羊羊是大美女！"}))));
        System.out.println("OK");
    }

    /**
     * 添加数据
     * */
    @Test
    public void get_case()
    {
        MyClient myClient = new MyClient();
        //ByteBuffer buffer = MyConvertUtil.toByteBuffer(new Object[] {8, "美羊羊是大美女！"});
        List<Byte> buffer = MyConvertUtil.objToListBytes(8);
        String rs = (String) MyConvertUtil.restoreToObject(myClient.executeNoSql("nosql_cache", "get", buffer));
        System.out.println(rs);
        //System.out.println(MyConvertUtil.toObj(myClient.executeNoSql("nosql_cache", "set", MyConvertUtil.toByteBuffer(new Object[] {8, "美羊羊是大美女！"}))));
        System.out.println("OK");
    }
}




































